package cn.example.backstage.appointment.service.impl;

import cn.example.backstage.appointment.mapper.AppointmentRegisterMapper;
import cn.example.backstage.appointment.pojo.dto.AppointmentAddDTO;
import cn.example.backstage.appointment.pojo.dto.AppointmentQuery;
import cn.example.backstage.appointment.pojo.vo.AppointmentVO;
import cn.example.backstage.appointment.service.AppointmentRegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class AppointmentRegisterServiceImpl implements AppointmentRegisterService {
    @Autowired
    AppointmentRegisterMapper appointmentRegisterMapper;
    @Override
    public List<AppointmentVO> selectAll(AppointmentQuery appointmentQuery) {
        List<AppointmentVO> list = appointmentRegisterMapper.select(appointmentQuery);
        return list;
    }
    @Override
    public void addAppointment(AppointmentAddDTO appointmentAddDTO) {
        if (appointmentAddDTO.getId() == null){
            appointmentRegisterMapper.insert(appointmentAddDTO);
        }else {
            appointmentRegisterMapper.update(appointmentAddDTO);
        }
    }
    @Override
    public void deleteById(Long id) {
        appointmentRegisterMapper.deleteById(id);
    }
}
